Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend/sdoc_source_code: recognize C++ class declarations/definitions #2018

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

stanislaw
Copy link
Collaborator

No description provided.

@stanislaw stanislaw added this to the 2024-Q4 milestone Nov 23, 2024
@stanislaw stanislaw force-pushed the stanislaw/cpp branch 2 times, most recently from 7856a81 to f71866a Compare November 23, 2024 01:05
@johanenglund
Copy link
Contributor

This PR asserts for me on this code:

class TrkVertex
{
   public:
    double x_ = 0;  //!< mm, x axis pointing right
    double y_ = 0;  //!< mm, y axis pointing up

    TrkVertex& operator-=(const TrkVertex& c);
};

TrkVertex& TrkVertex::operator-=(const TrkVertex& c)
{
    x_ -= c.x_;
    y_ -= c.y_;

    return *this;
}
  File "/home/johan/virtual_python/lib/python3.12/site-packages/strictdoc/core/file_traceability_index.py", line 437, in create_traceability_info
    function_.name
AssertionError: function name:  function: Function(parent = SourceFileTraceabilityInfo(...), name = "", child_functions = [], markers = [], line_begin = 40, line_end = 46, attributes = set(1 elements)) attributes: {<FunctionAttribute.DEFINITION: 'definition'>} source_file_rel_path: src_cs/cmn/trk_primitives.cc

@johanenglund
Copy link
Contributor

johanenglund commented Nov 23, 2024

Also asserts on overloaded constructors defined in class:

class TrkVertex
{
   public:
    TrkVertex() {}
    TrkVertex(double x, double y) {}
};

@johanenglund
Copy link
Contributor

I added the following in reader_c.py around row 220 to get a little bit further. Sorry, no patch.

                        # C++ function definition inside class, e.g., class CPPClass {foo(){}};
                        elif child_.children[0].type == "field_identifier":
                            assert child_.children[0].text
                            function_name = child_.children[0].text.decode(
                                "utf8"
                            )
                        # C++ destructor, e.g. CPPClass::~foo()
                        elif child_.children[0].type == "destructor_name":
                            assert child_.children[0].text
                            function_name = child_.children[0].text.decode(
                                "utf8"
                            )

@stanislaw stanislaw merged commit 6deba29 into main Nov 23, 2024
13 checks passed
@stanislaw stanislaw deleted the stanislaw/cpp branch November 23, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants